Code resources consist of functions that are invoked by a calling computer program ("calling program"). These functions are referred to as the component functions of the code resource. Code resources are linked with the calling program at runtime, but the calling program is not directly linked to the component functions.
In order for a calling program to use a code resource, the calling program uses the following procedure. First, the calling program loads the code resource into the allocated memory space of the calling program. Second, the calling program accesses and uses whichever component functions are desired. Finally, when the code resource is no longer needed, the code resource is purged from the allocated memory space of the calling program.
Typically, code resources contain one entry point to a dispatcher through which a calling program can access the component functions. The dispatcher is a function within the code resource. Therefore, a calling program cannot typically directly access the component functions of the code resource. Instead, when a calling program wants to execute a component function, the calling program invokes the dispatcher, passing an identifier of the requested component function as well as the parameters for the requested component function. The dispatcher determines the address of the component function and then invokes the component function, passing the parameters. Accessing component functions in this way ("indirectly") increases processing time, thereby degrading system performance.
FIG. 1 depicts a conventional code resource. The code resource consists of a main code resource 101 and auxiliary code resources 105, 106. The auxiliary code resources 105, 106 are code resources referred to by the main code resource 101. The main code resource contains a dispatcher 102, global variables 103, component functions 107, 108 and a jump table 104. The dispatcher 102 acts as the single entry point into the main code resource 101. The global variables 103 are variables that can be accessed by functions in either the main code resource 101 or the auxiliary code resources 105, 106. The jump table 104 contains entries that point to each component function contained in the auxiliary code resources 105, 106. A code resource that consists only of a main code resource is referred to as a single-segment code resource and a code resource with a main code resource and at least one auxiliary code resource is referred to as a multiple-segment code resource.
Using a prior "indirect access" method, a calling program 100 first loads the main code resource 101 into memory and performs a code resource initialization function. Next, the initialization function saves the base address of the main code resource 101 so that the component functions can access the global variables 103, which are at a fixed offset within the main code resource 101. The calling program 100 then calls the component functions of the code resource indirectly through the dispatcher 102.
To call a component function, the calling program 100 invokes the dispatcher 102 passing an identifier of the requested component function and the parameters for the requested component function. The dispatcher 102, in turn, invokes the requested component function passing the parameters. If the requested component function is contained within the main code resource 101, then the dispatcher 102 can simply invoke the component function passing the parameters. However, if the requested component function is contained in an auxiliary code resource 105, 106, then the dispatcher 102 loads the auxiliary code resource 105, 106 into memory (if not already loaded) and then calls the requested component function passing the parameters. An additional parameter passed to the component functions in an auxiliary code resource is the base address of the main code resource 101. The base address parameter allows the component functions of the auxiliary code resource to access the global variables 103 in the main code resource 101.
Another prior system provides direct access to component functions. The direct access prior system differs from typical prior systems in the way that the initialization function works and the way that the dispatcher works. In the direct access prior system, the initialization function of the calling program loads the main code resource into memory, determines the base address of the loaded main code resource, searches for a sequence of instructions and stores the base address at the location of the second and third instructions. Storing the base address in this way allows component functions in the main code resource to use global variables by executing the sequence of instructions to obtain the base address of the main code resource. The dispatcher of the direct access prior system can be requested to return the address of a component function. Thus, a calling program can use component functions directly. However, in using the direct access prior system, component functions which use global variables must reside within the main code resource because the main code resource is where the global variables are stored and the component functions in auxiliary code resources do not have access to the main code resource. Therefore, when using the direct access prior system, component functions in auxiliary code resources cannot use global variables.